<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增会议管理')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-management-add">
            <div class="form-group">    
                <label class="col-sm-3 control-label">文件名称：</label>
                <div class="col-sm-8">
                    <input id="mmName" name="mmName" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">文件上传：</label>
                <div class="col-sm-8">
                    <input id="mmUpload" name="file" class="form-control" type="file">
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">上传人：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input id="mmUploader" name="mmUploader" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">上传时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input id="mmUploadtime" name="mmUploadtime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "ruoyi/management"
        $("#form-management-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
               // $.operate.save(prefix + "/add", $('#form-management-add').serialize());
                uploadFile();
            }
        }
        function uploadFile() {
            var formData = new FormData();
            if ($('#mmUpload')[0].files[0] == null) {
                $.modal.alertWarning("请先选择文件路径");
                return false;
            }
            if ($('#mmUpload')[0].files[0] != null) {
                formData.append('mmName', $("#mmName").val());
                formData.append('file', $('#mmUpload')[0].files[0]);
                formData.append('mmUploadtime', $("#mmUploadtime").val());
                $.ajax({
                    url: prefix + "/add",
                    type: 'post',
                    cache: false,
                    data: formData,
                    processData: false,
                    contentType: false,
                    dataType: "json",
                    success: function (result) {
                        $.operate.successCallback(result);
                    }
                });
            }
        }
        $("input[name='mmUploadtime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>